import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xindong/common/xindong_sezhi.dart';
import 'package:xindong/common/xindong_define.dart';
import 'package:xindong/manager/xindong_page_singleton.dart';
import 'package:xindong/manager/xindong_user_controller.dart';
import 'package:xindong/res/assets_res.dart';
import 'package:xindong/routes/tab_moments/xindong_user_moments_yemian.dart';
import 'package:xindong/routes/user/auth/xindong_auth_yemian.dart';
import 'package:xindong/routes/user/noble/xindong_noble_yemian.dart';
import 'package:xindong/routes/user/visit/xindong_visit_yemian.dart';
import 'package:xindong/routes/user/wallet/xindong_recharge_yemian.dart';
import 'package:xindong/routes/user/wallet/xindong_wallet_yemian.dart';
import 'package:xindong/utils/xindong_image_util.dart';

class XinDongWoDeMoneyView extends StatelessWidget {
  const XinDongWoDeMoneyView({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 86,
      width: double.infinity,
      margin: const EdgeInsets.only(top: 10, left: kPaddingValue, right: kPaddingValue),
      decoration: BoxDecoration(color: DZColors.backgroundColor, borderRadius: BorderRadius.circular(10)),
      child: GetBuilder<XinDongUserController>(builder: (controller) {
        return Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            _buildItem("积分(${controller.income})", AssetsRes.ICON_MINE_WALLET, () {
              XinDongPageSingleton.instance.pushYeMian(const XinDongWalletYeMian());
            }),
            Container(width: 1, height: 20, color: DZColors.hexColor(0xdddddd)),
            _buildItem("金币(${controller.balance})", AssetsRes.ICON_MINE_COIN, () {
              XinDongPageSingleton.instance.pushYeMian(const XinDongRechargeYeMian());
            }),
            Container(width: 1, height: 20, color: DZColors.hexColor(0xdddddd)),
            _buildItem("SVIP会员", AssetsRes.ICON_MINE_NOBLE, () {
              XinDongPageSingleton.instance.pushYeMian(const XinDongNobleYeMian());
            }),
          ],
        );
      }),
    );
  }

  Widget _buildItem(String title, String iconName, Function() onTap) {
    return Expanded(
      flex: 1,
      child: GestureDetector(
        onTap: onTap,
        behavior: HitTestBehavior.opaque,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            ImageUtil.asset(iconName, width: 40, height: 40),
            const SizedBox(height: 5),
            Text(title, style: const TextStyle(fontSize: 13, color: DZColors.contentColor, height: 1.2)),
          ],
        ),
      ),
    );
  }
}
